1167A - Telephone Number - CodeForces Solution


brute force greedy strings *800

Please click on ads to support us..

C++ Code:

#include<bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
using namespace std;
//#define   int              long long
#define   endl            '\n'
#define   mod             1000000007
#define   pb              push_back
#define   operation();    ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   ff              first
#define   ss              second
#define   srt             sort(ar,ar+n)
#define   yes             cout<<"YES"<<endl;
#define   no              cout<<"NO"<<endl;
#define   cn              for(int i=0;i<n;i++) cin>>ar[i]
const int  inf=10e+15;

int dx[8] = {-1,0,1,1,1,0,-1,-1};
int dy[8] = {1,1,1,0,-1,-1,-1,0};
int  dx1[4] = {0,1,0,-1};
int  dy1[4] = {1,0,-1,0};
int  ar[300001];
int   arr[300001];
int  mm[300001];
int  arra[300001];
map<int ,int >mp;
map<pair<int,int>,int>mpp;
vector<int>vis[200001];
pair<int ,string>p[300001];
pair<int ,int >pr[200001];
int  a,b,c,d,e,f,t,k,sum,g,h,n,m,i,j;
//vector<int>v;
set<int >st;
int  gcd(int  a,int  b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
string s,s1,s2;
long long int dis[200001];
//vector<long long int>v(2000001);

vector<long long int >v;
queue<pair<int ,int > >q;
//int  ar[201][201];
pair<int,int>cr[300001];
int cnt=0;
int main()
{
    operation();
    int tt;
    cin>>tt;
    while(tt--)
    {
      string s;
      int n;
      cin>>n;
      cin>>s;
      int k=-1;
      for(int i=n-1;i>=0;i--)
      {
          if(s[i]=='8')
          {
              k=i;

          }
      }
   //   cout<<k<<endl;
      if(k==-1)
        no
      else
      {
      k=n-k;
      if(k>=11)
        yes
      else
        no;
      }


    }
}













Comments

Submit
0 Comments
More Questions

1352D - Alice Bob and Candies
1316D - Nash Matrix
1548B - Integers Have Friends
348A - Mafia
315B - Sereja and Array
204A - Little Elephant and Interval
385B - Bear and Strings
114C - Grammar Lessons
1427A - Avoiding Zero
583A - Asphalting Roads
1358B - Maria Breaks the Self-isolation
828A - Restaurant Tables
1735A - Working Week
1735D - Meta-set
1735B - Tea with Tangerines
1735C - Phase Shift
1321C - Remove Adjacent
281B - Nearest Fraction
1043A - Elections
1598C - Delete Two Elements
1400C - Binary String Reconstruction
1734D - Slime Escape
1499A - Domino on Windowsill
991A - If at first you don't succeed
1196C - Robot Breakout
373A - Collecting Beats is Fun
965A - Paper Airplanes
863E - Turn Off The TV
630E - A rectangle
1104A - Splitting into digits